/*=============================================================================
#     FileName: postfix.cpp
#         Desc: 转换中缀表达式到后缀表达式
#       Author: Ace
#        Email: goace@acm.org
#     HomePage: http://www.goace.co.cc
#      Version: 0.0.1
#   LastChange: 2011-06-14 14:57:09
#      History:
=============================================================================*/
#include  <stack>
#include  <iostream>
#include  <ctype.h>
using namespace std;

//若a优先级大于b 返回true
//若a优先级小于等于b 返回false
bool cmp(char a, char b)
{
	if( a == '+' || a == '-' )
	{
		return false;
	}
	else if( a == '*' || a == '/' )
	{
		if( b == '+' || b == '-' )
			return true;
		else
			return false;
	}
}

string topost(string& middle)
{
	stack<char> container;
	string postexp = "";

	for( int i = 0 ; i < middle.size() ; ++i )
	{
		if( isdigit(middle[i]) )
		{
			postexp += middle[i];
		}
		else if( middle[i] == '(' )
		{
			container.push(middle[i]);
		}
		else if( middle[i] == ')' )
		{
			while( container.top() != '(' )
			{
				postexp += container.top();
				container.pop();
			}
			container.pop();
		}
		else if( middle[i] == '+' || middle[i] == '-'
				|| middle[i] == '*' || middle[i] == '/')
		{
			if( container.empty() )
			{
				container.push(middle[i]);
			}
			else
			{
				if( container.top() == '(' )
				{
					container.push(middle[i]);
				}
				else if( cmp(middle[i],container.top()) )
				{
					container.push(middle[i]);
				}
				else
				{
					while( !container.empty() && container.top() != '('
							&& !cmp(middle[i],container.top()))
					{
						postexp += container.top();
						container.pop();
					}
					container.push(middle[i]);
				}
			}
		}
	}
	
	while( !container.empty() )
	{
		postexp += container.top();
		container.pop();
	}

	return postexp;
}

int main(int argc, char *argv[])
{
	string from,to;
	cin >> from;

	to = topost(from);

	for( int i = 0; i < to.size() ; ++i )
	{
		cout << to[i] << " ";
	}

	cout << endl;
	
}
